<%@ page import="aiball.League" %>

<!doctype html>
<html>
<head>
	<meta name="layout" content="main">
	<g:set var="entityName" value="${message(code: 'league.label', default: 'League')}" />
	<title>Liga-Verwaltung</title>
</head>
<body>
		<div id="uebersichtVerwaltung" class="content scaffold-create" role="main">
			<h1>Andere Ligen</h1>
			<g:if test="${flash.message}">
			<div class="message" role="status">${flash.message}</div>
			</g:if>
			<br>
			<div id="erstellteLigen" class="content scaffold-create" role="main">
				<table>
				<thead>
					<tr>
						<g:sortableColumn property="name" title="selbst erstellte Ligen" />
					</tr>
				</thead>
				<tbody>
				<g:if test="${aktuellEingeloggt==null}">
					<tr>
						<td>Sie müssen sich zuerst einloggen!</td>
					</tr>
				</g:if>
				<g:else>
				<g:each in="${leagueInstanceList}" status="i" var="leagueInstance">
					<g:if test="${leagueInstance.id!=1 && leagueInstance.admin==aktuellEingeloggt}">
						<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
							<td>${fieldValue(bean: leagueInstance, field: "name")}</td>
							<td><g:link action="show" id="${leagueInstance.id}">Anzeigen</g:link></td>
							<td><g:link action="edit" id="${leagueInstance.id}">Bearbeiten</g:link></td>
						</tr>
					</g:if>
				</g:each>
				</g:else>

				</tbody>
				</table>
			</div> 
			<br>
			<div id="gespielteLigen" class="content scaffold-create" role="main">
				<table>
				<thead>
					<tr>
						<g:sortableColumn property="name" title="teilgenommen" />
					</tr>
				</thead>
				<tbody>
				<g:each in="${leagueInstanceList}" status="i" var="leagueInstance">
					<g:if test="${leagueInstance.id!=1}">
						<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
							<td>${fieldValue(bean: leagueInstance, field: "name")}</td>
							<td><g:link action="show" id="${leagueInstance.id}">Anzeigen</g:link></td>
						</tr>
					</g:if>
				</g:each>
				</tbody>
				</table>
			</div> 
			<div id="sonstigeLigen" class="content scaffold-create" role="main">
				<table>
				<thead>
					<tr>
						<g:sortableColumn property="name" title="sonstige Ligen" />
					</tr>
				</thead>
				<tbody>
				<g:each in="${leagueInstanceList}" status="i" var="leagueInstance">
					<g:if test="${leagueInstance.id!=1}">
						<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
							<td>${fieldValue(bean: leagueInstance, field: "name")}</td>
							<td><g:link action="join" id="${leagueInstance.id}">Teilnehmen</g:link></td>
						</tr>
					</g:if>
				</g:each>
				</tbody>
				</table>
			</div> 
			<div id="buttonsLigaVerwaltung" class="content scaffold-create" role="main">
				<fieldset class="buttons">
					<g:submitButton name="create" action="create" class="create" value="Neue Liga erstellen" />
				</fieldset>
			</div>
		</div>
</body>

</html>